$(document).ready(function () {

    $.setDateController(type);        //set times
    var  gridDatas, $form = $('#scopeSearch');        //form
    //buttons
    $('#collapse').click(function(){            //收展
        $('#queryItems').toggle('slow');
        var isCol = $(this).attr('data');
        if (isCol == 'true') {
            $(this).val("收起查询条件");
            $(this).attr('data', 'false');
        } else {
            $(this).val("展开查询条件");
            $(this).attr('data', 'true');
        }
    }).button();

    $('#analyseBtn').click(function () {
        $.ajax({
            url: $form.attr('action'),
            type: $form.attr('method'),
            dataType: 'json',
            data: $form.serializeArray().concat(itemIds).concat(siteItems), 
            success: function(datas){
                gridDatas = datas;
                var bodys = gridDatas.bodys, footers = gridDatas.footers;
                $gridTable.setFooterDatas(footers);
                
                $('#exportBtn').button({ disabled: false });
                $('#printBtn').button({ disabled: false });
                $('#genChartBtn').button({ disabled: false });
            }
        });
    });
});